package eventmanager.backend.event;

public class Event extends EventList{
	
	/**
	 * 
	 */
	private final String name;

	private final int day, month, year, hour, min;
	
	//Constructor
	public Event(String eventName, int monthEvent, int dayEvent, int yearEvent, int hourEvent, int minEvent){
		this.name = eventName;
		this.day = dayEvent;
		this.month = monthEvent;
		this.year = yearEvent;
		this.hour = hourEvent;
		this.min = minEvent;
	}
	
	//Adds an event to the ArrayList
	public static void addEvent(Event event){
		eventList.add(event);
		//eventMap.put(event.name, event);
	}
	
	public int getDay(){
		return this.day;
	}
	
	public int getMonth(){
		return this.month;
	}
	
	public int getYear(){
		return this.year;
	}
	
	public int getHour(){
		return this.hour;
	}
	
	public int getMin(){
		return this.min;
	}
	
	public String getName(){
		return this.name;
	}
	
	@Override
	public String toString() {
		System.out.print("'" +name+ "'");
		System.out.print(" " +month);
		System.out.print("/" +day);
		System.out.print("/" +year);
		if(hour < 10)
			System.out.print("  0" + hour + ":");
		else
			System.out.print("  " + hour + ":");
		if(min < 10)
			System.out.println("0" + min);
		else
			System.out.println(min);
		return super.toString();
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + day;
		result = prime * result + month;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + year;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Event other = (Event) obj;
		if (day != other.day)
			return false;
		if (month != other.month)
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (year != other.year)
			return false;
		return true;
	}

	public static void main(String[] args){
		new EventList();
		EventManager i = new EventManager();
		Event a = new Event("Test", 2, 25, 1990, 10, 43);
		System.out.println("Adding event to a list");
		addEvent(a);
		System.out.println(a);
		System.out.println(eventList.size());
		System.out.println("...");
		i.goThroughArray(eventList);
		Event b = new Event("Weeeee", 3, 17, 1992,8, 5);
		addEvent(b);
		System.out.println(eventList.size());
		i.goThroughArray(eventList);
		//i.printToText(eventList);
		System.out.println("...");
	}
	
}
